######### Tables in Appendix ########


###### Table D1 PM party baseline model ########## 
attach(pm_filter_data)
set.seed(1234567)

base.mod.1<- lme(
  fixed = vipm_filtered ~ l.vipm_filtered+austerity_12m,
  random = ~ 1+l.vipm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.1)
LMtest.base.mod.1<-pdwtest(plm(vipm_filtered ~ l.vipm_filtered+austerity_12m,
                               data = pm_filter_pdata, model="random"))$p.value


base.mod.2<- lme(
  fixed = vipm_filtered ~ l.vipm_filtered+austerity_6m,
  random = ~ 1+l.vipm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.2)
LMtest.base.mod.2<-pdwtest(plm(vipm_filtered ~ l.vipm_filtered+austerity_6m,
                               data = pm_filter_pdata, model="random"))$p.value


base.mod.3<- lme(
  fixed = vipm_filtered ~ l.vipm_filtered+austerity_3m,
  random = ~ 1+l.vipm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.3)
LMtest.base.mod.3<-pdwtest(plm(vipm_filtered ~ l.vipm_filtered+austerity_3m,
                               data = pm_filter_pdata, model="random"))$p.value


base.mod.4<- lme(
  fixed = vipm_filtered ~ l.vipm_filtered+austerity_12m 
  + d.unemployment+ retail+ imf+protest_freq,
  random = ~ 1+l.vipm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.4)
LMtest.base.mod.4<-pdwtest(plm(vipm_filtered ~ l.vipm_filtered+austerity_12m 
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = pm_filter_pdata, model="random"))$p.value


base.mod.5<- lme(
  fixed = vipm_filtered ~ l.vipm_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq,
  random = ~ 1+l.vipm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.5)
LMtest.base.mod.5<-pdwtest(plm(vipm_filtered ~ l.vipm_filtered+austerity_6m
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = pm_filter_pdata, model="random"))$p.value


base.mod.6<- lme(
  fixed = vipm_filtered ~ l.vipm_filtered+austerity_3m
  + d.unemployment+ retail+ imf+protest_freq,
  random = ~ 1+l.vipm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.6)
LMtest.base.mod.6<-pdwtest(plm(vipm_filtered ~ l.vipm_filtered+austerity_3m
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = pm_filter_pdata, model="random"))$p.value


htmlreg(list(base.mod.1,
             base.mod.2,
             base.mod.3,
             base.mod.4,
             base.mod.5,
             base.mod.6),file = "TableD1.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
        reorder.coef=c(2,3,4,5,6,7,8,9,1))

as.data.frame(rbind(LMtest.base.mod.1,
                    LMtest.base.mod.2,
                    LMtest.base.mod.3,
                    LMtest.base.mod.4,
                    LMtest.base.mod.5,
                    LMtest.base.mod.6))

###### Table D2 PM party Interactions  ########## 

attach(pm_filter_data)
set.seed(1234567)

int.mod.2<- lme(
  fixed = vipm_filtered ~ l.vipm_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq+austerity_6m*d.unemployment,
  random = ~ 1+l.vipm_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.2)
LMtest.int.mod.2<-pdwtest(plm(vipm_filtered ~ l.vipm_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*d.unemployment,
                              data = pm_filter_pdata, model="random"))$p.value


int.mod.5<- lme(
  fixed = vipm_filtered ~ l.vipm_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq+austerity_6m*imf,
  random = ~ 1+l.vipm_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.5)
LMtest.int.mod.5<-pdwtest(plm(vipm_filtered ~ l.vipm_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*imf,
                              data = pm_filter_pdata, model="random"))$p.value


int.mod.8<- lme(
  fixed = vipm_filtered ~ l.vipm_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq+austerity_6m*protest_freq,
  random = ~ 1+l.vipm_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.8)
LMtest.int.mod.8<-pdwtest(plm(vipm_filtered ~ l.vipm_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*protest_freq,
                              data = pm_filter_pdata, model="random"))$p.value


int.mod.11<- lme(
  fixed = vipm_filtered ~ l.vipm_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq
  +austerity_6m*d.unemployment++austerity_6m*imf++austerity_6m*protest_freq,
  random = ~ 1+l.vipm_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.11)
LMtest.int.mod.11<-pdwtest(plm(vipm_filtered ~ l.vipm_filtered+austerity_6m
                               + d.unemployment+ retail+ imf+protest_freq
                               +austerity_6m*d.unemployment++austerity_6m*imf++austerity_6m*protest_freq,
                               data = pm_filter_pdata, model="random"))$p.value


htmlreg(list(int.mod.2,
             int.mod.5,
             int.mod.8,
             int.mod.11),file = "TableD2.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
        reorder.coef=c(2,3,4,5,6,7,8,9,10,1))

as.data.frame(rbind(LMtest.int.mod.2,
                    LMtest.int.mod.5,
                    LMtest.int.mod.8,
                    LMtest.int.mod.11))



###### Table D3 FM party baseline model ########## 
attach(fm_filter_data)
set.seed(1234567)

base.mod.1<- lme(
  fixed = vifm_filtered ~ l.vifm_filtered+austerity_12m,
  random = ~ 1+l.vifm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.1)
LMtest.base.mod.1<-pdwtest(plm(vifm_filtered ~ l.vifm_filtered+austerity_12m,
                               data = fm_filter_pdata, model="random"))$p.value


base.mod.2<- lme(
  fixed = vifm_filtered ~ l.vifm_filtered+austerity_6m,
  random = ~ 1+l.vifm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.2)
LMtest.base.mod.2<-pdwtest(plm(vifm_filtered ~ l.vifm_filtered+austerity_6m,
                               data = fm_filter_pdata, model="random"))$p.value


base.mod.3<- lme(
  fixed = vifm_filtered ~ l.vifm_filtered+austerity_3m,
  random = ~ 1+l.vifm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.3)
LMtest.base.mod.3<-pdwtest(plm(vifm_filtered ~ l.vifm_filtered+austerity_3m,
                               data = fm_filter_pdata, model="random"))$p.value


base.mod.4<- lme(
  fixed = vifm_filtered ~ l.vifm_filtered+austerity_12m 
  + d.unemployment+ retail+ imf+protest_freq,
  random = ~ 1+l.vifm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.4)
LMtest.base.mod.4<-pdwtest(plm(vifm_filtered ~ l.vifm_filtered+austerity_12m 
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = fm_filter_pdata, model="random"))$p.value


base.mod.5<- lme(
  fixed = vifm_filtered ~ l.vifm_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq,
  random = ~ 1+l.vifm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.5)
LMtest.base.mod.5<-pdwtest(plm(vifm_filtered ~ l.vifm_filtered+austerity_6m
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = fm_filter_pdata, model="random"))$p.value


base.mod.6<- lme(
  fixed = vifm_filtered ~ l.vifm_filtered+austerity_3m
  + d.unemployment+ retail+ imf+protest_freq,
  random = ~ 1+l.vifm_filtered | country, control = lmeControl(opt = 'optim'))
summary(base.mod.6)
LMtest.base.mod.6<-pdwtest(plm(vifm_filtered ~ l.vifm_filtered+austerity_3m
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = fm_filter_pdata, model="random"))$p.value


htmlreg(list(base.mod.1,
             base.mod.2,
             base.mod.3,
             base.mod.4,
             base.mod.5,
             base.mod.6),file = "TableD3.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
        reorder.coef=c(2,3,4,5,6,7,8,9,1))

as.data.frame(rbind(LMtest.base.mod.1,
                    LMtest.base.mod.2,
                    LMtest.base.mod.3,
                    LMtest.base.mod.4,
                    LMtest.base.mod.5,
                    LMtest.base.mod.6))

###### Table D4 FM party Interactions  ########## 

attach(fm_filter_data)
set.seed(1234567)

int.mod.2<- lme(
  fixed = vifm_filtered ~ l.vifm_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq+austerity_6m*d.unemployment,
  random = ~ 1+l.vifm_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.2)
LMtest.int.mod.2<-pdwtest(plm(vifm_filtered ~ l.vifm_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*d.unemployment,
                              data = fm_filter_pdata, model="random"))$p.value


int.mod.5<- lme(
  fixed = vifm_filtered ~ l.vifm_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq+austerity_6m*imf,
  random = ~ 1+l.vifm_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.5)
LMtest.int.mod.5<-pdwtest(plm(vifm_filtered ~ l.vifm_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*imf,
                              data = fm_filter_pdata, model="random"))$p.value


int.mod.8<- lme(
  fixed = vifm_filtered ~ l.vifm_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq+austerity_6m*protest_freq,
  random = ~ 1+l.vifm_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.8)
LMtest.int.mod.8<-pdwtest(plm(vifm_filtered ~ l.vifm_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*protest_freq,
                              data = fm_filter_pdata, model="random"))$p.value


int.mod.11<- lme(
  fixed = vifm_filtered ~ l.vifm_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq
  +austerity_6m*d.unemployment++austerity_6m*imf++austerity_6m*protest_freq,
  random = ~ 1+l.vifm_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.11)
LMtest.int.mod.11<-pdwtest(plm(vifm_filtered ~ l.vifm_filtered+austerity_6m
                               + d.unemployment+ retail+ imf+protest_freq
                               +austerity_6m*d.unemployment++austerity_6m*imf++austerity_6m*protest_freq,
                               data = fm_filter_pdata, model="random"))$p.value


htmlreg(list(int.mod.2,
             int.mod.5,
             int.mod.8,
             int.mod.11),file = "TableD4.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
        reorder.coef=c(2,3,4,5,6,7,8,9,10,1))

as.data.frame(rbind(LMtest.int.mod.2,
                    LMtest.int.mod.5,
                    LMtest.int.mod.8,
                    LMtest.int.mod.11))


###### Table D5 cabinet diff baseline model ########## 
attach(cabinet_diff_data)
set.seed(1234567)

base.mod.1<- lme(
  fixed = vicab_raw_diff ~ l.vicab_raw_diff+austerity_12m,
  random = ~ 1+l.vicab_raw_diff | country, control = lmeControl(opt = 'optim'))
summary(base.mod.1)
LMtest.base.mod.1<-pdwtest(plm(vicab_raw_diff ~ l.vicab_raw_diff+austerity_12m,
                               data = cabinet_diff_pdata, model="random"))$p.value


base.mod.2<- lme(
  fixed = vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m,
  random = ~ 1+l.vicab_raw_diff | country, control = lmeControl(opt = 'optim'))
summary(base.mod.2)
LMtest.base.mod.2<-pdwtest(plm(vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m,
                               data = cabinet_diff_pdata, model="random"))$p.value


base.mod.3<- lme(
  fixed = vicab_raw_diff ~ l.vicab_raw_diff+austerity_3m,
  random = ~ 1+l.vicab_raw_diff | country, control = lmeControl(opt = 'optim'))
summary(base.mod.3)
LMtest.base.mod.3<-pdwtest(plm(vicab_raw_diff ~ l.vicab_raw_diff+austerity_3m,
                               data = cabinet_diff_pdata, model="random"))$p.value


base.mod.4<- lme(
  fixed = vicab_raw_diff ~ l.vicab_raw_diff+austerity_12m 
  + d.unemployment+ retail+ imf+protest_freq,
  random = ~ 1+l.vicab_raw_diff | country, control = lmeControl(opt = 'optim'))
summary(base.mod.4)
LMtest.base.mod.4<-pdwtest(plm(vicab_raw_diff ~ l.vicab_raw_diff+austerity_12m 
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = cabinet_diff_pdata, model="random"))$p.value


base.mod.5<- lme(
  fixed = vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq,
  random = ~ 1+l.vicab_raw_diff | country, control = lmeControl(opt = 'optim'))
summary(base.mod.5)
LMtest.base.mod.5<-pdwtest(plm(vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = cabinet_diff_pdata, model="random"))$p.value


base.mod.6<- lme(
  fixed = vicab_raw_diff ~ l.vicab_raw_diff+austerity_3m
  + d.unemployment+ retail+ imf+protest_freq,
  random = ~ 1+l.vicab_raw_diff | country, control = lmeControl(opt = 'optim'))
summary(base.mod.6)
LMtest.base.mod.6<-pdwtest(plm(vicab_raw_diff ~ l.vicab_raw_diff+austerity_3m
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = cabinet_diff_pdata, model="random"))$p.value


htmlreg(list(base.mod.1,
             base.mod.2,
             base.mod.3,
             base.mod.4,
             base.mod.5,
             base.mod.6),file = "TableD5.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
        reorder.coef=c(2,3,4,5,6,7,8,9,1))

as.data.frame(rbind(LMtest.base.mod.1,
                    LMtest.base.mod.2,
                    LMtest.base.mod.3,
                    LMtest.base.mod.4,
                    LMtest.base.mod.5,
                    LMtest.base.mod.6))

###### Table D6 Cabinet diff Interactions  ########## 

attach(cabinet_diff_data)
set.seed(1234567)

int.mod.2<- lme(
  fixed = vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq+austerity_6m*d.unemployment,
  random = ~ 1+l.vicab_raw_diff | country, control = lmeControl(opt = 'optim'))
summary(int.mod.2)
LMtest.int.mod.2<-pdwtest(plm(vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*d.unemployment,
                              data = cabinet_diff_pdata, model="random"))$p.value


int.mod.5<- lme(
  fixed = vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq+austerity_6m*imf,
  random = ~ 1+l.vicab_raw_diff | country, control = lmeControl(opt = 'optim'))
summary(int.mod.5)
LMtest.int.mod.5<-pdwtest(plm(vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*imf,
                              data = cabinet_diff_pdata, model="random"))$p.value


int.mod.8<- lme(
  fixed = vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq+austerity_6m*protest_freq,
  random = ~ 1+l.vicab_raw_diff | country, control = lmeControl(opt = 'optim'))
summary(int.mod.8)
LMtest.int.mod.8<-pdwtest(plm(vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*protest_freq,
                              data = cabinet_diff_pdata, model="random"))$p.value


int.mod.11<- lme(
  fixed = vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq
  +austerity_6m*d.unemployment++austerity_6m*imf++austerity_6m*protest_freq,
  random = ~ 1+l.vicab_raw_diff | country, control = lmeControl(opt = 'optim'))
summary(int.mod.11)
LMtest.int.mod.11<-pdwtest(plm(vicab_raw_diff ~ l.vicab_raw_diff+austerity_6m
                               + d.unemployment+ retail+ imf+protest_freq
                               +austerity_6m*d.unemployment++austerity_6m*imf++austerity_6m*protest_freq,
                               data = cabinet_diff_pdata, model="random"))$p.value


htmlreg(list(int.mod.2,
             int.mod.5,
             int.mod.8,
             int.mod.11),file = "TableD6.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
        reorder.coef=c(2,3,4,5,6,7,8,9,10,1))

as.data.frame(rbind(LMtest.int.mod.2,
                    LMtest.int.mod.5,
                    LMtest.int.mod.8,
                    LMtest.int.mod.11))


###### Table D7 ivreg protest and retail interaction  ########## 

###### ivreg for protest ########
attach(cabinet_filter_data)
ivreg.protest <- ivreg(vicab_filtered~l.vicab_filtered+austerity_6m +d.unemployment+ retail+ protest_freq
                       |.-protest_freq + season + countryid + honeymoon + cabinetleft)
summary(ivreg.protest, vcov = sandwich, df = Inf, diagnostics = TRUE)


# with instrumented protest
first_stage<-lm(protest_freq ~ season + factor(countryid) + honeymoon + cabinetleft)
summary(first_stage)
protest_instrumented<-fitted.values(first_stage)
cabinet_filter_data$protest_instrumented<-protest_instrumented
cabinet_filter_pdata <- pdata.frame(cabinet_filter_data, index=c("country", "date_ym"))
attach(cabinet_filter_data)

int.mod.pro_instru<- lme(
  fixed = vicab_filtered ~ l.vicab_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_instrumented+austerity_6m*protest_instrumented,
  random = ~ 1+l.vicab_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.pro_instru)
LMtest.int.mod.pro_instru<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                                       + d.unemployment+ retail+ imf+protest_instrumented+austerity_6m*protest_instrumented,
                                       data = cabinet_filter_pdata, model="random"))$p.value

# retail as contextual
int.mod.retail<- lme(
  fixed = vicab_filtered ~ l.vicab_filtered+austerity_6m
  + d.unemployment+ retail+ imf+protest_freq+austerity_6m*retail,
  random = ~ 1+l.vicab_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.retail)
LMtest.int.mod.retail<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                                   + d.unemployment+ retail+ imf+protest_freq+austerity_6m*retail,
                                   data = cabinet_filter_pdata, model="random"))$p.value



htmlreg(list(ivreg.protest,
             int.mod.pro_instru,
             int.mod.retail
),file = "TableD7.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
reorder.coef=c(2,3,4,5,6,7,8,9,10,1))

as.data.frame(rbind(LMtest.int.mod.pro_instru,LMtest.int.mod.retail
))



###### Table D8 Interactions 12m 6m 3m ########## 

attach(cabinet_filter_data)
set.seed(1234567)

int.mod.1<- lme(
  fixed = vicab_filtered ~ l.vicab_filtered+austerity_12m
  + d.unemployment+ retail+ imf+protest_freq+austerity_12m*d.unemployment,
  random = ~ 1+l.vicab_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.1)
LMtest.int.mod.1<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_12m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_12m*d.unemployment,
                              data = cabinet_filter_pdata, model="random"))$p.value


int.mod.3<- lme(
  fixed = vicab_filtered ~ l.vicab_filtered+austerity_3m
  + d.unemployment+ retail+ imf+protest_freq+austerity_3m*d.unemployment,
  random = ~ 1+l.vicab_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.3)
LMtest.int.mod.3<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_3m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_3m*d.unemployment,
                              data = cabinet_filter_pdata, model="random"))$p.value



int.mod.4<- lme(
  fixed = vicab_filtered ~ l.vicab_filtered+austerity_12m
  + d.unemployment+ retail+ imf+protest_freq+austerity_12m*imf,
  random = ~ 1+l.vicab_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.4)
LMtest.int.mod.4<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_12m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_12m*imf,
                              data = cabinet_filter_pdata, model="random"))$p.value



int.mod.6<- lme(
  fixed = vicab_filtered ~ l.vicab_filtered+austerity_3m
  + d.unemployment+ retail+ imf+protest_freq+austerity_3m*imf,
  random = ~ 1+l.vicab_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.6)
LMtest.int.mod.6<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_3m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_3m*imf,
                              data = cabinet_filter_pdata, model="random"))$p.value


int.mod.7<- lme(
  fixed = vicab_filtered ~ l.vicab_filtered+austerity_12m
  + d.unemployment+ retail+ imf+protest_freq+austerity_12m*protest_freq,
  random = ~ 1+l.vicab_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.7)
LMtest.int.mod.7<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_12m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_12m*protest_freq,
                              data = cabinet_filter_pdata, model="random"))$p.value



int.mod.9<- lme(
  fixed = vicab_filtered ~ l.vicab_filtered+austerity_3m
  + d.unemployment+ retail+ imf+protest_freq+austerity_3m*protest_freq,
  random = ~ 1+l.vicab_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.9)
LMtest.int.mod.9<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_3m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_3m*protest_freq,
                              data = cabinet_filter_pdata, model="random"))$p.value

int.mod.10<- lme(
  fixed = vicab_filtered ~ l.vicab_filtered+austerity_12m
  + d.unemployment+ retail+ imf+protest_freq
  +austerity_12m*d.unemployment++austerity_12m*imf++austerity_12m*protest_freq,
  random = ~ 1+l.vicab_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.10)
LMtest.int.mod.10<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_12m
                               + d.unemployment+ retail+ imf+protest_freq
                               +austerity_12m*d.unemployment++austerity_12m*imf++austerity_12m*protest_freq,
                               data = cabinet_filter_pdata, model="random"))$p.value



int.mod.12<- lme(
  fixed = vicab_filtered ~ l.vicab_filtered+austerity_3m
  + d.unemployment+ retail+ imf+protest_freq
  +austerity_3m*d.unemployment++austerity_3m*imf++austerity_3m*protest_freq,
  random = ~ 1+l.vicab_filtered | country, control = lmeControl(opt = 'optim'))
summary(int.mod.12)
LMtest.int.mod.12<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_3m
                               + d.unemployment+ retail+ imf+protest_freq
                               +austerity_3m*d.unemployment++austerity_3m*imf++austerity_3m*protest_freq,
                               data = cabinet_filter_pdata, model="random"))$p.value


htmlreg(list(int.mod.1,
             int.mod.3,
             int.mod.4,
             int.mod.6,
             int.mod.7,
             int.mod.9,
             int.mod.10,
             int.mod.12),file = "Table_D8.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
        reorder.coef=c(2,3,9,4,5,6,7,8,10,11,12,13,14,1))

as.data.frame(rbind(LMtest.int.mod.1,
                    LMtest.int.mod.3,
                    LMtest.int.mod.4,
                    LMtest.int.mod.6,
                    LMtest.int.mod.7,
                    LMtest.int.mod.9,
                    LMtest.int.mod.10,
                    LMtest.int.mod.12))



###### Table D9 Fixed effects model ########## 

attach(cabinet_filter_pdata)
set.seed(1234567)

base.mod.1<- plm(vicab_filtered ~ l.vicab_filtered+austerity_12m,
                 data = cabinet_filter_pdata, model="within")
summary(base.mod.1)
LMtest.base.mod.1<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_12m,
                               data = cabinet_filter_pdata, model="within"))$p.value


base.mod.2<- plm(vicab_filtered ~ l.vicab_filtered+austerity_6m,
                 data = cabinet_filter_pdata, model="within")
summary(base.mod.2)
LMtest.base.mod.2<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m,
                               data = cabinet_filter_pdata, model="within"))$p.value


base.mod.3<- plm(vicab_filtered ~ l.vicab_filtered+austerity_3m,
                 data = cabinet_filter_pdata, model="within")
summary(base.mod.3)
LMtest.base.mod.3<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_3m,
                               data = cabinet_filter_pdata, model="within"))$p.value


base.mod.4<- plm(vicab_filtered ~ l.vicab_filtered+austerity_12m 
                 + d.unemployment+ retail+ imf+protest_freq,
                 data = cabinet_filter_pdata, model="within")
summary(base.mod.4)
LMtest.base.mod.4<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_12m 
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = cabinet_filter_pdata, model="within"))$p.value


base.mod.5<- plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                 + d.unemployment+ retail+ imf+protest_freq,
                 data = cabinet_filter_pdata, model="within")
summary(base.mod.5)
LMtest.base.mod.5<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = cabinet_filter_pdata, model="within"))$p.value


base.mod.6<- plm(vicab_filtered ~ l.vicab_filtered+austerity_3m
                 + d.unemployment+ retail+ imf+protest_freq,
                 data = cabinet_filter_pdata, model="within")
summary(base.mod.6)
LMtest.base.mod.6<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_3m
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = cabinet_filter_pdata, model="within"))$p.value


htmlreg(list(base.mod.1,
             base.mod.2,
             base.mod.3,
             base.mod.4,
             base.mod.5,
             base.mod.6),file = "Table_D9.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
        reorder.coef=c(1,2,3,4,5,6,7,8))

as.data.frame(rbind(LMtest.base.mod.1,
                    LMtest.base.mod.2,
                    LMtest.base.mod.3,
                    LMtest.base.mod.4,
                    LMtest.base.mod.5,
                    LMtest.base.mod.6))


###### Table D11 Random effects model ########## 

base.mod.1<- plm(vicab_filtered ~ l.vicab_filtered+austerity_12m,
                 data = cabinet_filter_pdata, model="random")
summary(base.mod.1)
LMtest.base.mod.1<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_12m,
                               data = cabinet_filter_pdata, model="random"))$p.value


base.mod.2<- plm(vicab_filtered ~ l.vicab_filtered+austerity_6m,
                 data = cabinet_filter_pdata, model="random")
summary(base.mod.2)
LMtest.base.mod.2<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m,
                               data = cabinet_filter_pdata, model="random"))$p.value


base.mod.3<- plm(vicab_filtered ~ l.vicab_filtered+austerity_3m,
                 data = cabinet_filter_pdata, model="random")
summary(base.mod.3)
LMtest.base.mod.3<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_3m,
                               data = cabinet_filter_pdata, model="random"))$p.value


base.mod.4<- plm(vicab_filtered ~ l.vicab_filtered+austerity_12m 
                 + d.unemployment+ retail+ imf+protest_freq,
                 data = cabinet_filter_pdata, model="random")
summary(base.mod.4)
LMtest.base.mod.4<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_12m 
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = cabinet_filter_pdata, model="random"))$p.value


base.mod.5<- plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                 + d.unemployment+ retail+ imf+protest_freq,
                 data = cabinet_filter_pdata, model="random")
summary(base.mod.5)
LMtest.base.mod.5<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = cabinet_filter_pdata, model="random"))$p.value


base.mod.6<- plm(vicab_filtered ~ l.vicab_filtered+austerity_3m
                 + d.unemployment+ retail+ imf+protest_freq,
                 data = cabinet_filter_pdata, model="random")
summary(base.mod.6)
LMtest.base.mod.6<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_3m
                               + d.unemployment+ retail+ imf+protest_freq,
                               data = cabinet_filter_pdata, model="random"))$p.value


htmlreg(list(base.mod.1,
             base.mod.2,
             base.mod.3,
             base.mod.4,
             base.mod.5,
             base.mod.6),file = "Table_D11.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
        reorder.coef=c(2,3,4,5,6,7,8,9,1))

as.data.frame(rbind(LMtest.base.mod.1,
                    LMtest.base.mod.2,
                    LMtest.base.mod.3,
                    LMtest.base.mod.4,
                    LMtest.base.mod.5,
                    LMtest.base.mod.6))


###### Table D10 Interactions Fixed effect  ########## 

attach(cabinet_filter_data)
set.seed(1234567)

int.mod.2<-plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
               + d.unemployment+ retail+ imf+protest_freq+austerity_6m*d.unemployment,
               data = cabinet_filter_pdata, model="within")
summary(int.mod.2)
LMtest.int.mod.2<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*d.unemployment,
                              data = cabinet_filter_pdata, model="within"))$p.value


int.mod.5<- plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                + d.unemployment+ retail+ imf+protest_freq+austerity_6m*imf,
                data = cabinet_filter_pdata, model="within")
summary(int.mod.5)
LMtest.int.mod.5<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*imf,
                              data = cabinet_filter_pdata, model="within"))$p.value


int.mod.8<- plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                + d.unemployment+ retail+ imf+protest_freq+austerity_6m*protest_freq,
                data = cabinet_filter_pdata, model="within")
summary(int.mod.8)
LMtest.int.mod.8<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*protest_freq,
                              data = cabinet_filter_pdata, model="within"))$p.value


int.mod.11<- plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                 + d.unemployment+ retail+ imf+protest_freq
                 +austerity_6m*d.unemployment++austerity_6m*imf++austerity_6m*protest_freq,
                 data = cabinet_filter_pdata, model="within")
summary(int.mod.11)
LMtest.int.mod.11<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                               + d.unemployment+ retail+ imf+protest_freq
                               +austerity_6m*d.unemployment++austerity_6m*imf++austerity_6m*protest_freq,
                               data = cabinet_filter_pdata, model="within"))$p.value


htmlreg(list(int.mod.2,
             int.mod.5,
             int.mod.8,
             int.mod.11),file = "Table_D10.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T)

as.data.frame(rbind(LMtest.int.mod.2,
                    LMtest.int.mod.5,
                    LMtest.int.mod.8,
                    LMtest.int.mod.11))


###### Table D12 Interactions Random effect  ########## 

attach(cabinet_filter_data)
set.seed(1234567)

int.mod.2<-plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
               + d.unemployment+ retail+ imf+protest_freq+austerity_6m*d.unemployment,
               data = cabinet_filter_pdata, model="random")
summary(int.mod.2)
LMtest.int.mod.2<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*d.unemployment,
                              data = cabinet_filter_pdata, model="random"))$p.value


int.mod.5<- plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                + d.unemployment+ retail+ imf+protest_freq+austerity_6m*imf,
                data = cabinet_filter_pdata, model="random")
summary(int.mod.5)
LMtest.int.mod.5<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*imf,
                              data = cabinet_filter_pdata, model="random"))$p.value


int.mod.8<- plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                + d.unemployment+ retail+ imf+protest_freq+austerity_6m*protest_freq,
                data = cabinet_filter_pdata, model="random")
summary(int.mod.8)
LMtest.int.mod.8<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                              + d.unemployment+ retail+ imf+protest_freq+austerity_6m*protest_freq,
                              data = cabinet_filter_pdata, model="random"))$p.value


int.mod.11<- plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                 + d.unemployment+ retail+ imf+protest_freq
                 +austerity_6m*d.unemployment++austerity_6m*imf++austerity_6m*protest_freq,
                 data = cabinet_filter_pdata, model="random")
summary(int.mod.11)
LMtest.int.mod.11<-pdwtest(plm(vicab_filtered ~ l.vicab_filtered+austerity_6m
                               + d.unemployment+ retail+ imf+protest_freq
                               +austerity_6m*d.unemployment++austerity_6m*imf++austerity_6m*protest_freq,
                               data = cabinet_filter_pdata, model="random"))$p.value


htmlreg(list(int.mod.2,
             int.mod.5,
             int.mod.8,
             int.mod.11),file = "Table_D12.doc",digits = 3,stars = c(0.001, 0.01, 0.05, 0.1),caption.above = T,
        reorder.coef=c(2,3,4,5,6,7,8,9,10,1))

as.data.frame(rbind(LMtest.int.mod.2,
                    LMtest.int.mod.5,
                    LMtest.int.mod.8,
                    LMtest.int.mod.11))


